<!DOCTYPE html>
<html>

<body>

    <?php

echo "-------------------------------- tt begin ---------------------------------\n";


//引用其它模块
//include "tt2.php";
//require "tt2.php";

echo '-------------------基础测试'.PHP_EOL;

echo "get params, qw:".$_GET['qw'].", gr:".$_GET['gr']."\n<br>";
echo "Hello rr5  World!\n<br>"; 
echo "1+2+3=:", 1 +2 + 3, "\n<br>"; 
echo "curl version:".var_export(curl_version())."\n<br>".PHP_EOL;

echo '-------------------数组测试'.PHP_EOL;
$arr1 = array(1, 2, 3, 4, 5);
foreach ($arr1 as $v) {
    echo $v." | ";
}
echo PHP_EOL;

echo '-------------------关联数组测试'.PHP_EOL;
$arr2 = array(
    'id' => 231,
    'name' => 'rr5',
    'age' => 25,
);
foreach ($arr2 as $k => $v) {
    echo $k.":".$v." | ";
}
echo PHP_EOL;


$a = 112;
echo 'a defined:'.isset($a).PHP_EOL;
echo 'b defined:'.isset($b).PHP_EOL;

function a() {
    //1 要在一个函数中访问一个全局变量，需要使用 global 关键字。
    echo "global a = ".$GLOBALS['a'].PHP_EOL;

    //2 在函数内调用函数外定义的全局变量，我们需要在函数中的变量前加上 global 关键字
    global $a;
    echo "a = ".$a.PHP_EOL;
}
a();

echo '-------------------日期测试'.PHP_EOL;
date_default_timezone_set("PRC");
echo 'date:'.date('y/m/d H:i:s')."\n<br>";
echo 'date 1:'.(int)gettimeofday(true)."\n<br>";

echo '-------------------switch'.PHP_EOL;
$num = 2;
switch ($num) {
    case 1:
        echo "num is 1".PHP_EOL;
        break;  //防止继续执行后续代码
    case 2:
        echo "num is 2".PHP_EOL;
        break;
    default:
        echo "num is 1 or 2".PHP_EOL;
        break;
}


//-----------------------------------------------------

echo "-------------------------------- tt end ---------------------------------\n";

?>

</body>

</html>


<!-- http://47.96.22.83:8187/tphp/tt.php -->


<!-- thinkphp5文档参考: https://www.kancloud.cn/manual/thinkphp5_1/353960 -->